package com.hgm.flopgame2.activity

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.view.View
import android.view.WindowManager
import android.widget.Toast
import com.hgm.flopgame2.R
import com.hgm.flopgame2.databinding.ActivityLoginBinding

class LoginActivity : AppCompatActivity() {

    private val binding: ActivityLoginBinding by lazy {
        ActivityLoginBinding.inflate(layoutInflater)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(binding.root)
        //隐藏状态栏
        window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)

        binding.btnLogin.setOnClickListener {
            login()
        }
    }

    private fun login() {
        //判空
        var name = binding.etName.text.toString()
        if (TextUtils.isEmpty(name)) {
            Toast.makeText(this, "用户名不能为空", Toast.LENGTH_SHORT).show()
            return
        }


        //进入主界面答题，传递名字过去
        val intent = Intent(this, MainActivity::class.java)
        intent.putExtra("name", name)
        startActivityForResult(intent, 1)
    }
}